package com.pvdnc.tapkit.chat.chat;

import com.pvdnc.encrypt.IEncrypt;
import com.pvdnc.encrypt.Xor;
import com.pvdnc.nsocket.EndPoint;
import com.pvdnc.nsocket.client.BaseClient;
import com.pvdnc.nsocket.log.SLog;
import com.pvdnc.nsocket.protocol.base.Packet;
import com.pvdnc.tapkit.chat.chat.client.ClientReadyReceiver;
import com.pvdnc.tapkit.chat.chat.client.KeyManager;
import com.pvdnc.tapkit.chat.chat.client.OnFriendResponse;
import com.pvdnc.tapkit.chat.chat.client.OnMessageReceived;
import com.pvdnc.tapkit.chat.chat.packet.ClientHello;
import com.pvdnc.tapkit.chat.chat.packet.InterpreterUtils;
import com.pvdnc.tapkit.chat.chat.packet.TextMessage;
import com.pvdnc.tapkit.utils.LocalBroadcast;

import io.netty.channel.ChannelPipeline;

public class ChatClient extends BaseClient {
    private static final SLog LOG=new SLog(ChatClient.class);

    public final KeyManager mKeyManager=new KeyManager();

    public ChatClient(EndPoint endPoint, byte[] key) {
        super(endPoint,new Xor(key));
    }

    @Override
    public void onConnected() {
            LOG.d("on client connected");
        ClientReadyReceiver.broadcast();
    }

    @Override
    public void addWorkHandlers(ChannelPipeline pipeline) {
        pipeline.addLast(new OnMessageReceived(this));
        pipeline.addLast(new OnFriendResponse(this));
    }

    @Override
    public Packet onPreClose() {
        return null;
    }
}
